import {
  legacy_createStore as createStore,
  applyMiddleware,
} from "redux"
import thunk from "redux-thunk"
// 引入 redux-thunk ,用于支持异步action

import reducers from "./reducers"
import { composeWithDevTools } from "redux-devtools-extension"

// 使用开发者工具
// const modulesFiles = require.context("./modules/", true, /\.js$/)
// const modules = modulesFiles.keys().reduce((modules, modulePath) => {
//   const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, "$1")
//   const value = modulesFiles(modulePath)
//   modules[moduleName] = value.default
//   return modules
// }, {})
// console.log(modules)

export default createStore(
  reducers,
  // applyMiddleware(thunk)
  composeWithDevTools(applyMiddleware(thunk))
  // 使用开发者工具
)
